<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:t="http://myfaces.apache.org/tomahawk"
      xmlns:v="http://shale.apache.org/validator">

    <f:view>
        <f:loadBundle var="text" basename="#{customerForm.bundleName}"/>
        <head>
            <title>#{text['customerForm.title']}</title>
            <meta name="menu" content="CustomerManagement"/>
            <meta name="heading" content="#{text['customerForm.heading']}"/>
        </head>

        <div class="separator"></div>
        <h:form id="customerForm" onsubmit="return validateCustomerForm(this)">
            <input type="hidden" name="from" value="#{customerForm.from}" />
            <h:inputHidden value="#{customerForm.customer.id}"/>

            <c:set var="addText" value="#{text['button.add']}"/>
            <h:panelGrid columns="2" styleClass="info">
                <h:outputText value="#{text['customerForm.message']}" styleClass="left"/>
            </h:panelGrid>
            <h:panelGrid columns="1">

                <h:outputLabel for="name" styleClass="desc" value="#{text['customer.name']}"/>
                <h:inputText value="#{customerForm.customer.name}" id="name" required="true" styleClass="text large">
                    <v:commonsValidator client="true" type="required" arg="#{text['customer.name']}"/>
                </h:inputText>

                <h:outputLabel for="representative" value="#{text['customer.representative']}" styleClass="desc"/>

                <h:inputText value="#{customerForm.customer.representative}" id="representative" styleClass="text large">
                </h:inputText>

                <h:outputLabel for="title" value="#{text['customer.title']}" styleClass="desc"/>

                <h:inputText value="#{customerForm.customer.title}" id="title" styleClass="text large">
                </h:inputText>

                <h:outputLabel for="address" value="#{text['customer.address']}" styleClass="desc"/>

                <h:inputText value="#{customerForm.customer.address}" id="address" styleClass="text large">
                </h:inputText>

                <h:panelGroup style="vertical-align: middle">
                    <t:htmlTag value="div">
                        <t:htmlTag value="div">
                            <h:outputLabel for="phone" value="#{text['customer.phone']}" styleClass="desc"/>

                            <h:inputText id="phone" value="#{customerForm.customer.phone}" maxlength="50" styleClass="text medium">
                            </h:inputText>
                        </t:htmlTag>
                        <t:htmlTag value="div">
                            <h:outputLabel for="fax" value="#{text['customer.fax']}" styleClass="desc"/>
                            <h:inputText value="#{customerForm.customer.fax}" id="fax" maxlength="50" styleClass="text medium">
                            </h:inputText>
                        </t:htmlTag>
                    </t:htmlTag>
                </h:panelGroup>

                <h:outputLabel for="account" value="#{text['customer.account']}" styleClass="desc"/>

                <h:inputText value="#{customerForm.customer.account}" id="account" styleClass="text large">
                </h:inputText>

                <h:outputLabel for="taxCode" value="#{text['customer.taxCode']}" styleClass="desc"/>

                <h:inputText value="#{customerForm.customer.account}" id="taxCode" styleClass="text large">
                </h:inputText>

                <h:outputLabel for="dateCreated" value="#{text['customer.dateCreated']}" styleClass="desc"/>
                <h:inputText readonly="true" disabled="true" value="#{customerForm.customer.dateCreated}" id="dateCreated" styleClass="text large">
                </h:inputText>
                <h:outputText></h:outputText>
                <h:outputText></h:outputText>

                <h:panelGroup styleClass="buttonBar bottom">
                    <h:commandButton value="#{text['button.save']}" action="#{customerForm.save}" styleClass="button"/>
                    <c:if test="${not empty customerForm.customer.id}">
                        <h:commandButton value="#{text['button.delete']}" action="#{customerForm.delete}"
                                         styleClass="button" onclick="bCancel=true; return confirmDelete('User')"/>
                    </c:if>
                    <h:commandButton value="#{text['button.cancel']}" action="#{customerForm.cancel}" immediate="true"
                                     styleClass="button" onclick="bCancel=true"/>
                </h:panelGroup>
                <h:outputText/><h:outputText/>
            </h:panelGrid>
        </h:form>

        <v:validatorScript functionName="validateCustomerForm"/>
        <script type="text/javascript">
            Form.focusFirstElement($('customerForm'));
            highlightFormElements();
        </script>
    </f:view>
</html>
